<template>
  <div class="upd-order">
    <el-dialog v-el-drag-dialog="{ drag: true, full: true, resize: false }" :title="fm.ps.isCopy ? '复制订单' : '修改订单'"
      :close-on-click-modal="false" :visible="true" @close="closeMd" custom-class="upd-order-md" :width="dialogWidth">
      <el-tabs v-model="tabActiveName" @tab-click="clickTab">
        <el-tab-pane label="普通包车" name="ptcar" v-if="order.isTrans == 0">
          <el-form class="upd-order-fm" :model="fm.ps" :ref="fm.fname">
            <el-row type="flex">
              <el-form-item label="用车单位" label-width="80px" style="margin-right: 30px;"
                :rules="[{ required: true, message: '请搜索并选择用车单位', trigger: 'change' }]">
                <el-input v-model="queryCusPageList_find" @change="queryCusPageList_change" placeholder="搜索用车单位"
                  style="width: 120px;">
                </el-input>
                <el-select v-model="fm.ps.useCarUname" clearable filterable :placeholder="'搜索选择用车单位'" :remote="true"
                  :remote-method="queryCusPageList" style="width: 135px;">
                  <el-option v-for="it in cusList" :key="it.baseUserId.uname"
                    :label="it.baseUserId.realName + '【' + it.unitName + '】'" :value="it.baseUserId.uname"
                    @click.native="selUseCarCus(it, 1)">
                    <span>{{ it.baseUserId.realName + '【' + it.unitName + '】' }}</span>
                    <span>{{ it.baseUserId.phone }}</span>
                  </el-option>
                </el-select>

                <i class="el-icon-circle-plus add-btn" title="添加用车单位" @click="setAddCusMd({ state: true })"></i>
              </el-form-item>

              <el-form-item label="联系人" prop="operator" label-width="65px" style="margin-right: 10px;"
                :rules="[{ required: true, message: '请选择联系人', trigger: 'change' }]">
                <el-select v-model="fm.ps.operator" clearable filterable placeholder="联系人选择" style="width: 110px;">
                  <el-option v-for="it in operatorList" :key="it.uname" :label="it.realName" :value="it.uname">
                    <span>{{ it.realName }}</span>
                    <span style="font-size: 12px;">{{ it.phone }}</span>
                  </el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="乘车人" prop="routeLink.name" label-width="65px" style="margin-right: 10px;" :rules="[
                { required: true, message: '请输入乘车人姓名', trigger: 'blur' },
                { min: 2, max: 10, message: '长度在 2 到 10 个字符', trigger: 'blur' }
              ]">
                <el-input v-model="fm.ps.routeLink.name" placeholder="乘车人姓名" style="width: 100px;">
                </el-input>
              </el-form-item>

              <el-form-item label="电话" prop="routeLink.phone" label-width="50px" style="margin-right: 10px;" :rules="[
                { required: true, message: '请输入客户电话', trigger: 'blur' },
                { min: 11, max: 11, message: '电话号码为数字', trigger: 'blur' }
              ]">
                <el-input v-model="fm.ps.routeLink.phone" placeholder="客户电话" style="width: 110px;">
                </el-input>
              </el-form-item>

              <el-form-item label="业务员" prop="serviceMan.uname" label-width="65px"
                :rules="[{ required: true, message: '请选择业务员', trigger: 'change' }]">
                <el-select v-model="fm.ps.serviceMan.uname" clearable filterable placeholder="业务员选择"
                  style="width: 110px;">
                  <el-option v-for="it in serviceManList" :key="it.baseUserId.uname" :label="it.baseUserId.realName"
                    :value="it.baseUserId.uname" @click.native="selServiceMan(it.baseUserId)">
                    <span>{{ it.baseUserId.realName }}</span>
                    <span>{{ it.baseUserId.phone }}</span>
                  </el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="团号" prop="groupNum" label-width="55px" style="margin-right: 10px;" :rules="[
                { required: false, message: '请输入行程团号', trigger: 'blur' },
                { min: 1, max: 50, message: '长度在 1 到 50 个字符', trigger: 'blur' }
              ]">
                <el-input v-model="fm.ps.groupNum" placeholder="行程团号" style="width: 80px;">
                </el-input>
              </el-form-item>

              <el-form-item label="行程简称" prop="routeShort" style="margin-bottom: 0;" label-width="80px" :rules="[
                { required: true, message: '请选择行程简称', trigger: 'change' }]">
                <el-input maxlength="5" v-if="fm.ps.routeShort == '包车'" v-model="routeShort_value" placeholder="行程简称"
                  show-word-limit style="width: 110px"></el-input>
                <el-select @change="routeShortchange" v-model="fm.ps.routeShort" clearable placeholder="行程简称 "
                  style="width: 115px;margin-left:10px ">
                  <el-option v-for="item in JourneyAbbreviation" :key="item.value" :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>


              </el-form-item>



              <el-form-item label-width="0px" style="width: 40px;margin-left: 10px;">
                <el-button title="航班查询工具" type="danger" icon="el-icon-search" circle
                  @click="flightSearchMd({ state: true, name: 'wpoint' })">
                </el-button>
              </el-form-item>
            </el-row>

            <div class="add-route-line">
              <el-form-item style="margin-bottom: 0;">
                <fragment v-for="(obj, index) in fm.ps.dayRoutes" :key="index">
                  <el-row type="flex">
                    <el-form-item :prop="`dayRoutes.${index}.goDate`" style="margin-right: 10px;" :rules="[
                      { required: true, message: '请选择行程日期', trigger: 'blur' }
                    ]">
                      <el-date-picker v-model="obj.goDate" type="date" :value-format="'yyyy-MM-dd'" placeholder="行程日期"
                        @change="onChangeDate($event, index)" style="width: 125px;">
                      </el-date-picker>
                    </el-form-item>

                    <el-form-item :prop="`dayRoutes.${index}.spoint.name`" style="width: 125px;margin-right: 10px;"
                      :rules="[
                        { required: true, message: '请选择开始地点', trigger: 'bulr' }
                      ]">
                      <MapPointInp v-if="stationList.length > 0" :name="'spoint'" :pindex="index" :placeholder="'开始地点'"
                        :defList="stationList" :point="obj.epoint" :defPoint="obj.spoint" @handleSel="setPoint" />
                    </el-form-item>

                    <el-form-item :prop="`dayRoutes.${index}.stime`" style="margin-right: 10px;" :rules="[
                      { required: true, message: '请选择开始时间', trigger: 'blur' },
                      { pattern: /^(?:(?:[0-2][0-3])|(?:[0-1][0-9])):[0-5][0-9]$/, message: '时间格式错误' }
                    ]">
                      <TimeInp :pindex="`${index}`" :name="'stime'" :defval="obj.stime" :tip="'开始时间'" :iconName="'stime'"
                        @pclick="timeInp" />
                    </el-form-item>

                    <el-form-item style="width: 150px; margin-right: 10px;">
                      <MapPointList :name="'amPoints'" :pindex="`${index}`" :placeholder="'上午行程'" :vallist="obj.amPoints"
                        @handleSel="setPoint" />
                    </el-form-item>

                    <el-form-item :prop="`dayRoutes.${index}.lunchPoint.name`" style="width: 110px;margin-right: 10px;">
                      <MapPointInp :name="'lunchPoint'" :pindex="index" :placeholder="'午餐地点'" :defList="[]"
                        :defPoint="obj.lunchPoint" @handleSel="setPoint" />
                    </el-form-item>

                    <el-form-item style="width: 150px; margin-right: 10px;">
                      <MapPointList :name="'pmPoints'" :pindex="`${index}`" :placeholder="'下午行程'" :vallist="obj.pmPoints"
                        @handleSel="setPoint" />
                    </el-form-item>

                    <el-form-item :prop="`dayRoutes.${index}.epoint.name`" style="width: 125px;margin-right: 10px;"
                      :rules="[
                        { required: true, message: '请选择结束地点', trigger: 'blur' }
                      ]">
                      <MapPointInp v-if="stationList.length > 0" :name="'epoint'" :pindex="index" :placeholder="'结束地点'"
                        :defList="stationList" :point="obj.spoint" :defPoint="obj.epoint" @handleSel="setPoint" />
                    </el-form-item>

                    <el-form-item style="margin-right: 10px;" :prop="`dayRoutes.${index}.etime`" :rules="[
                      { required: true, message: '请选择结束时间', trigger: 'blur' },
                      { pattern: /^(?:(?:[0-2][0-3])|(?:[0-1][0-9])):[0-5][0-9]$/, message: '时间格式错误' }
                    ]">
                      <TimeInp :pindex="`${index}`" :name="'etime'" :defval="obj.etime" :tip="'结束时间'" :iconName="'etime'"
                        @pclick="timeInp" />
                    </el-form-item>

                    <el-form-item style="margin-right: 10px;">
                      <el-button type="primary" icon="el-icon-time" plain size="mini"
                        @click="autoCalcDayRouteEtime(index, obj)" title="点击自动计算结束时间">
                        自动计算
                      </el-button>
                    </el-form-item>

                    <el-form-item style="margin-right: 10px;" :prop="`dayRoutes.${index}.wayHighSpeed`">
                      <el-input placeholder="途径高速" clearable v-model="obj.wayHighSpeed" style="width: 160px;">
                        <i slot="prefix" style="line-height: 26px;">
                          <SvgIcon :svgName="'hight-speed'" :width="'16px'" :height="'16px'" />
                        </i>
                      </el-input>
                    </el-form-item>

                    <el-form-item>
                      <el-button title="增加" type="danger" icon="el-icon-circle-plus" circle @click="addDayRoute(index)">
                      </el-button>

                      <el-button v-if="fm.ps.dayRoutes.length > 1" title="删除" type="info" icon="el-icon-remove" circle
                        @click="delDayRoute(index)">
                      </el-button>
                    </el-form-item>
                  </el-row>
                </fragment>
              </el-form-item>
            </div>

            <el-row type="flex">
              <el-form-item label="座位" prop="seats" style="margin-right: 10px;" label-width="50px" :rules="[
                { required: true, message: '请填写座位数', trigger: 'blur' },
                this.$rules.isPosInt()
              ]">
                <el-input v-model.number="fm.ps.seats" placeholder="座位数"
                  :disabled="(order && (order.plateNum && order.isCopy != 1)) ? true : false" style="width: 140px;">
                </el-input>
              </el-form-item>

              <el-form-item label="人数" prop="customers" style="margin-right: 10px;" label-width="50px" :rules="[
                { required: true, message: '请填写人数数', trigger: 'blur' },
                this.$rules.isPosInt()
              ]">
                <el-input v-model.number="fm.ps.customers" placeholder="人数" style="width: 100px;"><span
                    slot="suffix">人</span></el-input>
              </el-form-item>

              <el-form-item label="运价" prop="transportPrice" style="margin-right: 10px;" label-width="50px" :rules="[
                { required: true, message: '请输入运价', trigger: 'blur' },
                this.$rules.isFloat()
              ]">
                <el-input v-model.number="fm.ps.transportPrice" placeholder="运价" @blur="calcOrderTotalPrice"
                  style="width: 140px;">
                  <span slot="suffix">￥</span>
                </el-input>
              </el-form-item>

              <el-form-item label="天数" prop="cars" style="margin-right: 10px;" label-width="65px" :rules="[
                { required: true, message: '请填写天数', trigger: 'blur' },
                this.$rules.isPosInt()
              ]">
                <el-input type="number" v-model="fm.ps.useCarDays" placeholder="天数" @blur="calcOrderTotalPrice"
                  style="width: 90px;"><span slot="suffix">天</span></el-input>
              </el-form-item>

              <!-- <el-form-item 
                label="车辆数" 
                prop="cars"
                style="margin-right: 10px;"
                label-width="65px"
                :rules="[ 
                  { required: true, message: '请填写车辆数', trigger: 'blur' }, 
                  this.$rules.isPosInt() 
                ]">
                <el-input 
                  v-model.number="fm.ps.cars" 
                  placeholder="车辆数"
                  @blur="calcOrderTotalPrice"
                  :disabled="(order && (order.isCopy != 1 && order.isMain != 1)) ? true : false"
                  style="width: 140px;">
                </el-input> 
              </el-form-item> -->

              <el-form-item label="其他费用" prop="otherFees" style="margin-right: 10px;" label-width="70px" :rules="[
                { required: false, message: '请输入其他费用', trigger: 'blur' },
                this.$rules.isFloat()
              ]">
                <el-input v-model.number="fm.ps.otherFees" placeholder="其他费用" @blur="calcOrderTotalPrice"
                  style="width: 155px;"><span slot="suffix">￥</span></el-input>
              </el-form-item>

              <el-form-item label="师傅现收" prop="remindRouteCash" style="margin-right: 10px;" label-width="70px" :rules="[
                { required: false, message: '请输入师傅现收', trigger: 'blur' },
                this.$rules.isFloat()
              ]">
                <el-input v-model.number="fm.ps.remindRouteCash" placeholder="师傅现收" @blur="calcOrderTotalPrice"
                  style="width: 155px;">
                  <span slot="suffix">￥</span>
                </el-input>
              </el-form-item>

              <el-form-item label="订单总价" prop="orderTotalPrice" label-width="70px" style="margin-right: 10px;">
                <el-input v-model.number="fm.ps.orderTotalPrice" placeholder="自动计算" :readonly="true"
                  style="width: 175px;">
                  <span slot="suffix">￥</span>
                </el-input>
              </el-form-item>
            </el-row>

            <el-row type="flex" class="text-note">
              <el-form-item label="行程" prop="routeDetail" label-width="35px">
                <el-input type="textarea" autosize placeholder="行程详情内容（不能修改）"
                  :value="fm.ps.routeDetail.replace(/@/g, '\n')" :readonly="true" style="width: 610px;">
                </el-input>
              </el-form-item>

              <el-form-item label="客户备注" prop="cusNote" label-width="35px">
                <el-input type="textarea" autosize placeholder="客户备注（所有人都能看到）" maxlength="100" show-word-limit
                  v-model="fm.ps.cusNote" style="width: 200px;">
                </el-input>
              </el-form-item>

              <el-form-item label="驾驶员备注" prop="driverNote" label-width="35px">
                <el-input type="textarea" autosize placeholder="驾驶员备注内容" maxlength="100" show-word-limit
                  v-model="fm.ps.driverNote" style="width: 200px;">
                </el-input>
              </el-form-item>

              <el-form-item label="业务员备注" prop="salesmanNote" label-width="35px">
                <el-input type="textarea" autosize placeholder="业务员备注内容" maxlength="100" show-word-limit
                  v-model="fm.ps.salesmanNote" style="width: 200px;">
                </el-input>
              </el-form-item>
            </el-row>

            <el-row>
              <el-col :span="2">
                <el-checkbox v-model="fm.ps.isNotice" :true-label="1" :false-label="0">
                  通知驾驶员
                </el-checkbox>
              </el-col>

              <el-col :span="22">
                <div style="text-align: center;">
                  <el-button type="primary" @click="onSubmit()" :disabled="fm.sb.load">
                    {{ fm.sb.text }}
                  </el-button>

                  <el-button type="success" v-if="!fm.ps.isCopy">
                    <el-popover class="tb-popover" trigger="click" placement="top" :width="800">
                      <el-table :ref="dg.tbName" :data="dg.list" row-key="orderNum" border fit
                        :height="40 * dg.list.length" :max-height="500" @selection-change="selRowChange"
                        style="min-height: 100px;">
                        <el-table-column type="selection" width="40"></el-table-column>
                        <el-table-column prop="orderNum" label="行程编号" width="140"></el-table-column>
                        <el-table-column prop="dayRoutes.0.goDate" label="出发日期" width="80"></el-table-column>
                        <el-table-column prop="routeDetail" label="行程详情"></el-table-column>
                      </el-table>
                      <div slot="reference">同步修改订单</div>
                    </el-popover>
                  </el-button>
                </div>
              </el-col>
            </el-row>

            <el-row>
              <div class="page-explain">
                <span>保存行程订单：保存成功后关闭页面。</span>
              </div>
            </el-row>
          </el-form>
        </el-tab-pane>

        <el-tab-pane label="交通车" name="jtcar" v-if="order.isTrans == 1">
          <AddTrafficCar :order="order" :allServiceManList="allServiceManList" @getMdState="closeMd"
            @reloadDg="getDgList" />
        </el-tab-pane>
      </el-tabs>
    </el-dialog>

    <AddCus v-if="addCusMd.state" @myClick="setAddCusMd" @reloadDg="setCusDat" />

    <FlightSearch v-if="md.flightSearch.state" :dat="md.flightSearch" @getMdState="flightSearchMd" />

  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import elDragDialog from '@/directive/el-drag-dialog';
import SvgIcon from '@/components/SvgIcon';
import TimeInp from '@/components/TimeInp';
import AddCus from '../../add-cus';
import MapPointInp from '@/components/MapPointInp';
import MapPointList from '@/components/MapPointList';
import FlightSearch from '@/components/FlightSearch';
import AddTrafficCar from '../add-traffic-car';

import * as commonSer from '@/api/services/common.service';
import * as orderService from '@/api/services/order.service';

// 每日行程
let dayRoute = {
  no: '',               // 编号
  goDate: '',           // 出发日期 2021-01-01
  spoint: {             // 出发地点 
    address: '',        // 地址详情 成都市 武侯区 天府广场
    name: '',           // 地址简称 天府广场
    lnglat: '',         // 地点坐标 140.xxxxxx,30.xxxxxx
    isSta: false
  },
  stime: '',            // 开始时间
  amPoints: [],         // 上午地点数组
  lunchPoint: {         // 午餐地点
    address: '',        // 地址详情 成都市 武侯区 天府广场
    name: '',           // 地址简称 天府广场
    lnglat: '',         // 地点坐标 140.xxxxxx,30.xxxxxx
  },
  pmPoints: [],         // 下午行程
  dinnerPoint: {        // 晚餐地点
    address: '',        // 地址详情 成都市 武侯区 天府广场
    name: '',           // 地址简称 天府广场
    lnglat: '',         // 地点坐标 140.xxxxxx,30.xxxxxx
  },
  epoint: {             // 结束地点
    address: '',        // 地址详情 成都市 武侯区 天府广场
    name: '',           // 地址简称 天府广场
    lnglat: '',         // 地点坐标 140.xxxxxx,30.xxxxxx
    isSta: false
  },
  etime: '',            // 结束时间   
  wayHighSpeed: '',     // 途径高速    
  seStaInfo: null,      // 开始/结束地点的航班/车次查询信息
};

export default {
  name: 'UpdOrder',
  directives: { elDragDialog },
  props: ['state', 'order', 'allServiceManList'],
  components: {
    SvgIcon,
    TimeInp,
    AddCus,
    MapPointInp,
    MapPointList,
    FlightSearch,
    AddTrafficCar
  },
  computed: { ...mapGetters(['lunitNum', 'uname']) },
  data() {
    return {
      queryCusPageList_find: "",
      JourneyAbbreviation: [{
        value: '送天府',
        label: '送天府'
      }, {
        value: '接天府',
        label: '接天府'
      }, {
        value: '拼车送天府',
        label: '拼车送天府'
      }, {
        value: '拼车接天府',
        label: '拼车接天府'
      },
      {
        value: '送双流',
        label: '送双流'
      }, {
        value: '接双流',
        label: '接双流'
      }, {
        value: '送东站',
        label: '送东站'
      }, {
        value: '接东站',
        label: '接东站'
      }, {
        value: '送西站',
        label: '送西站'
      }, {
        value: '接西站',
        label: '接西站'
      }, {
        value: '送南站',
        label: '送南站'
      }, {
        value: '接南站',
        label: '接南站'
      }, {
        value: '送集合点',
        label: '送集合点'
      }, {
        value: '接集合点',
        label: '接集合点'
      }, {
        value: '包车',
        label: '包车'
      }],
      routeShort_value: "",
      // 弹框高度
      dialogWidth: this.U.fullWidth() < 1480 ? '98%' : '1500px',
      // 选项卡默认选中tab名称
      tabActiveName: 'ptcar',
      // 添加客户-弹框
      addCusMd: { state: false },
      md: {
        addPoints: { state: false, name: '', tip: '', opoint: null },     // 添加-多个地图地点
        flightSearch: { // 航班查询弹框
          state: false, // 弹框开关状态
          name: '',     // 查询标记
          date: '',     // 查询日期
          type: '',     // 交通类型 1-飞机 2-火车
          jsType: '',   // 接送类型 1-接 2-送
          staPoint: null// 站点对象
        },
      },
      fm: {
        fname: 'updOrderFm',
        sb: { load: false, text: '立即修改' },
        ps: {
          // 订单编号
          orderNum: this.order.orderNum,
          // 操作员
          operator: '',
          // 用车客户              
          useCarUname: '',
          // 乘车人：张三-13588888888            
          routeLink: { name: '', phone: '' },
          // 业务员：张三-13588888888-U8888888888
          serviceMan: { name: '', phone: '', uname: '' },
          // 团号
          groupNum: '',
          // 行程简称           
          routeShort: '',
          // 天数行程数组         
          dayRoutes: [],
          // 座位数           
          seats: '',
          // 人数           
          customers: '',
          // 车辆数                
          cars: 1,
          // 运价            
          transportPrice: 0,
          // 天数                
          useCarDays: 1,
          // 其他费用       
          otherFees: '',
          // 订单总价         
          orderTotalPrice: '',
          // 定金       
          deposit: '',
          // 师傅现收             
          remindRouteCash: '',
          // 途径高速      
          // wayHighSpeed: '',  
          // 订单业务类型         
          orderServiceType: '',
          // 行程详情   
          routeDetail: '',
          // 客户备注          
          cusNote: '',
          // 驾驶员备注          
          driverNote: '',
          // 业务员备注         
          salesmanNote: '',
          // 是否通知驾驶员
          isNotice: 0,
        },
      },
      // 操作员列表
      operatorList: [],
      // 用车客户列表       
      cusList: [],
      // 业务员列表            
      serviceManList: [],
      // 接送机站点列表   
      stationList: [],
      // 修改的子订单同级订单列表      
      dg: {
        dgName: 'dg',
        tbName: 'otherOrderListTb',
        list: [],
        selRows: [],
      },
    }
  },
  watch: {
    // 监控每日行程数据改变
    'fm.ps.dayRoutes': {
      handler(c, o) {
        const that = this;

        // 自动生成行程详情
        that.creatRouteText();
      },
      deep: true // true=深度监听
    }
  },
  async created() {
    const that = this;

    console.log('回填的订单对象', that.order);

    // 获取所有站点
    that.getStationList();

    // 加载业务员列表
    if (that.allServiceManList && that.allServiceManList.length > 0) {
      that.serviceManList = that.allServiceManList;
    }
    /**************以上是基础数据准备********************/

    // 如果存在回填订单对象
    if (that.order) {
      // 如果是交通车，则只显示交通车的tab，否则显示普通包车的tab
      if (that.order.isTrans == 1) {// 交通车
        that.tabActiveName = 'jtcar';
        that.clickTab({ index: 1 });
      } else {// 普通包车
        that.tabActiveName = 'ptcar';
        that.clickTab({ index: 0 });
      }

      that.fm.ps = Object.assign(that.fm.ps, that.order);

      // 其他子订单
      let list = that.order.otherOrders || [];
      list.forEach(it => { it.dgName = that.dg.dgName; });
      that.dg.list = list;

      // 回填选择客户对应的操作员
      let selCus = that.cusList.find(it => it.baseUserId.uname == that.fm.ps.useCarUname);
      if (selCus) that.selUseCarCus(selCus, 0);

      // 获取指定用车单位
      let res = await commonSer.queryComboCusPageList({ page: 1, rows: 20, find: that.order.useCarUname });
      if (res && res.code == 1) {
        that.cusList = res.data;

        // 回填选择客户对应的操作员
        let selCus = that.cusList.find(it => it.baseUserId.uname == that.fm.ps.useCarUname);
        if (selCus) that.selUseCarCus(selCus, 0);
      }

      // 如果是’复制‘功能，则修改按钮名称
      if (that.fm.ps.isCopy) that.fm.sb.text = '立即复制';

      // 自动生成行程详情
      that.creatRouteText();
    }
  },
  methods: {
    // 行程简章选择的值
    routeShortchange(e) {
    },
    /* 关闭弹框 */
    closeMd() {
      this.$emit('getMdState', false);
    },
    // 点击tab事件
    clickTab(e) {
      console.log('tab', e);

      const that = this, U = that.U;

      if (e.index == 0) {// 普通包车
        that.dialogWidth = U.fullWidth() < 1380 ? '98%' : '1500px';
      } else if (e.index == 1) {// 交通车
        that.dialogWidth = U.fullWidth() < 1435 ? '98%' : '1435px';
      }
    },
    // 子组件通信函数
    timeInp(e) {
      this.fm.ps.dayRoutes[e.pindex][e.name] = e.val;
    },
    /**
     * 获取-接送机站点列表
     */
    getStationList() {
      const that = this;

      commonSer.getStationList({}).then(res => {
        if (res && res.code == 1) {
          let list = res.data;

          list.forEach(it => {
            that.stationList.push({
              id: it.id,                    // id
              type: it.type,                // 类型 1-飞机 2-火车
              isSta: true,                  // 是否是站点地点
              lnglat: it.mapPoint.lngLat,   // 坐标
              area: it.county,              // 区域
              name: it.name,                // 地点简写
              address: it.mapPoint.address, // 地址
              note: it.nameNote             // 站点别名
            });
          });
        }
      });
    },
    /**
     * 获取-业务员列表
     */
    getServiceManList() {
      const that = this;

      commonSer.getServiceManList({}).then(res => {
        if (res && res.code == 1) {
          that.serviceManList = res.data;
        }
      });
    },
    queryCusPageList_change() {
      const that = this;

      commonSer.queryComboCusPageList({ page: 1, rows: 20, find: that.queryCusPageList_find }).then(res => {
        console.log('queryCusPageList_find')
        if (res && res.code == 1) that.cusList = res.data;
      });
    },
    /**
     * 获取-单位客户列表（用于下拉框）
     * @param find 客户手机号/用户名
     */
    queryCusPageList(find) {
      const that = this;

      commonSer.queryComboCusPageList({ page: 1, rows: 20, find: find }).then(res => {
        if (res && res.code == 1) that.cusList = res.data;
      });
    },
    /**
     * 选择-用车客户-获取操作员
     * @param obj 客户对象
     * @param t 0-不修改其他关联数据 1-修改其他关联数据
     */
    selUseCarCus(obj, t) {
      const that = this;

      // 检查业务员列表中是否存在业务员列表中
      let sm = that.serviceManList.find(it => it.baseUserId.uname == obj.serviceMan.split('-')[1]);
      if (sm) {
        if (t == 1) that.selServiceMan(sm.baseUserId);

        // 设置乘车人信息（添加时才修改 2022.2.8）
        if (t == 1) that.fm.ps.routeLink = { name: sm.baseUserId.realName, phone: sm.baseUserId.phone };
      } else {
        that.selServiceMan(null);
        that.fm.ps.routeLink = { name: '', phone: '' };
      }

      // 根据客户用户名获取对应的业务员
      orderService.geDutysByCuList({ cusUname: obj.baseUserId.uname }).then(res => {
        if (res && res.code == 1) {
          that.operatorList = res.data;

          // 设置默认选中值
          that.fm.ps.operator = that.operatorList.length > 0 ? that.operatorList[0].uname : '';
        } else {
          that.operatorList = [];

          // 设置默认选中值
          that.fm.ps.operator = '';
        }
      });
    },
    // 业务员-选择事件
    selServiceMan(obj) {
      const that = this;

      that.fm.ps.serviceMan = {
        name: obj ? obj.realName : '',
        phone: obj ? obj.phone : '',
        uname: obj ? obj.uname : '',
      };
    },
    /**
     * 生成-行程详情
     */
    creatRouteText() {
      let that = this, U = that.U, drs = that.fm.ps.dayRoutes;

      let routeText = '';
      drs.forEach((it, index) => {
        let rdText = '';

        // 必要的数据都存在，才生成
        if (it.goDate && it.spoint.name && it.stime && it.epoint.name && it.etime) {
          // // 出发时间 03月01日08:00出发
          // rdText += U.datefmt(it.goDate+' '+it.stime, 'MM月dd号 HH:mm').replace(' ', '');

          if (it.seStaInfo && it.seStaInfo.jsType == 1) {// 接机
            if (it.seStaInfo.type == 1) {// 接机
              if (!it.seStaInfo.arrScheduled) {
                // 8号起飞，01:20到达xxx机场接EU6666
                rdText += U.datefmt(it.seStaInfo.downUpTime, 'MM月dd号') + '起飞，' + it.stime + '到达';
              } else {
                // 到达时间日期不与所选出发日期一样，则表示到达时间跨天
                if (it.seStaInfo.arrScheduled && it.goDate != it.seStaInfo.arrScheduled.split(' ')[0]) {
                  // 8号起飞，9号01:20到达xxx机场接EU6666
                  rdText += U.datefmt(it.seStaInfo.depScheduled, 'MM月dd号') + '起飞，' + it.seStaInfo.arrScheduled.substring(8, 10) + '号' + it.stime + '到达';
                } else {
                  // 8号起飞，9号01:20到达xxx机场接EU6666
                  rdText += U.datefmt(it.seStaInfo.depScheduled, 'MM月dd号') + '起飞，' + it.seStaInfo.arrScheduled.substring(8, 10) + '号' + it.stime + '到达';
                }
              }
            } else {// 接车
              // 出发时间 03月01日08:00出发
              rdText += U.datefmt(it.goDate + ' ' + it.stime, 'MM月dd号 HH:mm').replace(' ', '');
            }
          } else {
            // 出发时间 03月01日08:00出发
            rdText += U.datefmt(it.goDate + ' ' + it.stime, 'MM月dd号 HH:mm').replace(' ', '');
          }

          // 开始地址
          rdText += it.spoint.name;

          if (it.seStaInfo && it.seStaInfo.flightTrainNo != 'null') {
            if (it.seStaInfo.jsType == 1) {
              rdText += `接${it.seStaInfo.flightTrainNo}`;
            } else {
              rdText += `接团`;
            }
          } else {
            rdText += '接团';
          }

          // 上午行程地址 都江堰→青城山
          if (it.amPoints) {
            let amAddrs = '';
            it.amPoints.forEach(amit => { amAddrs = `${amAddrs}→${amit.name}`; });
            if (amAddrs) rdText += amAddrs;
          }

          // 午餐地址 都江堰王鸡肉（本身午餐地点对象不为空，name可能为空）
          if (it.lunchPoint && it.lunchPoint.name) rdText = `${rdText}→${it.lunchPoint.name}`;

          // 下午行程地址 街子古镇→怀远古镇
          if (it.pmPoints) {
            let pmAddrs = '';
            it.pmPoints.forEach(pmit => { pmAddrs = `${pmAddrs}→${pmit.name}`; });
            if (pmAddrs) rdText += pmAddrs;
          }

          // 晚餐地址 崇州饭店
          if (it.dinnerPoint && it.dinnerPoint.name) rdText = `${rdText}→${it.dinnerPoint.name}`;

          // 处理最后一个箭头（→），如果最后一位是箭头，则去掉
          if (rdText.lastIndexOf('→') == rdText.length - 1) {
            rdText = rdText.slice(0, rdText.length - 1);
          }

          // 结束时间 18点
          rdText += `，${it.etime}`;
          // 如果结束时间小于开始时间，则表示跨天了，需要在后面加一个日期
          if (U.str2date(`${it.goDate} ${it.stime}`).getTime() > U.str2date(`${it.goDate} ${it.etime}`).getTime()) {
            rdText += `（${U.addDayForTime(it.goDate, 1, 'MM月dd号')}）`
          }

          // 结束地址
          rdText += it.epoint.name;

          if (it.seStaInfo) {
            if (it.seStaInfo.jsType == 2) {
              rdText += `送${it.seStaInfo.flightTrainNo}完团`;
            } else {
              rdText += `完团`;
            }
          } else {
            // 单天或者多天行程的最后一条，显示“完团” 多天，显示“入住”
            rdText += (drs.length == 1 || index == drs.length - 1) ? '完团' : '入住';
          }

          // 途径高速 （途径都汶高速、京昆高速）
          let wayHighSpeed = it.wayHighSpeed;
          if (wayHighSpeed) rdText += `（途径${wayHighSpeed}）`;

          routeText += rdText + '@';
        }
      });

      that.fm.ps.routeDetail = routeText;
    },
    /** 选中修改订单同级数据发生改变事件 */
    selRowChange(selection) {
      this.dg.selRows = selection;
    },

    // 自动计算每日行程的结束时间
    autoCalcDayRouteEtime(index, row) {
      let that = this, U = that.U, fg = true, drs = that.fm.ps.dayRoutes, ps = {};

      console.log('当前行数据', row);

      if (fg) {
        if (!row.goDate) {
          fg = U.qerrorFalse('请选择行程出行日期');
        } else if (!row.stime) {
          fg = U.qerrorFalse('请填写行程出行时间');
        } else {
          ps.stime = `${row.goDate} ${row.stime}`;
        }
      }

      if (fg) {
        if (!row.spoint || !row.spoint.lnglat) {
          fg = U.qerrorFalse('请选择行程出发地点');
        } else {
          ps.spoint = row.spoint.lnglat;
        }
      }

      if (fg) {
        let wayPoints = [];// 存储途径地点

        // 上午行程地点
        if (row.amPoints && row.amPoints.length > 0) {
          row.amPoints.forEach(it => {
            wayPoints.push(it.lnglat);
          });
        }

        // 午餐地点
        if (row.lunchPoint && row.lunchPoint.lnglat) {
          wayPoints.push(row.lunchPoint.lnglat);
        }

        // 下午行程地点
        if (row.pmPoints && row.pmPoints.length > 0) {
          row.pmPoints.forEach(it => {
            wayPoints.push(it.lnglat);
          });
        }

        // 用分号拼接
        if (wayPoints.length > 0) ps.wayPoint = wayPoints.join(';');
      }

      if (fg) {
        if (!row.epoint || !row.epoint.lnglat) {
          fg = U.qerrorFalse('请选择行程到达地点');
        } else {
          ps.epoint = row.epoint.lnglat;
        }
      }
      console.log('提交参数', ps);

      if (fg) {
        commonSer.autoCalcDayRouteEtime(ps).then(res => {
          if (res.code == 1) {
            let edateTime = res.data;
            console.log('结束时间', edateTime);
            if (drs[index]) drs[index].etime = edateTime.split(' ')[1];
          }
        });
      }
    },

    /*********添加客户弹框***********/
    setAddCusMd(e) {
      const that = this;

      that.addCusMd.state = e.state;
      if (e.routeLink) that.fm.ps.routeLink = e.routeLink;
    },
    // 设置-数据
    setCusDat(e) {
      // 操作员/客户显示为当前添加的客户
      const that = this;

      that.operatorList.push(e);
      that.cusList.push(e);
    },
    /** 出发日期选择改变事件 */
    onChangeDate(e, index) {
      let that = this, U = that.U, drs = that.fm.ps.dayRoutes, resList = [];

      let dr = drs[index];
      if (dr) {
        // 遍历当前数组
        drs.forEach((it, i) => {
          if (i == index) {
            resList.push(it);
          } else if (i < index) {
            // 当前操作行之前的数据日期全部-1天（以当前操作行日期为基础依次-1）
            if (it.goDate) it.goDate = U.addDayForTime(e, -(index - i));
            resList.push(it);
          } else {
            // 当前操作行之后的数据日期全部+1天（以当前操作行日期为基础依次+1）
            if (it.goDate) it.goDate = U.addDayForTime(e, i - index);
            resList.push(it);
          }
        });
        that.fm.ps.dayRoutes = resList;
      }
    },
    // 选择地点后的回调函数
    setPoint(e) {
      let that = this, U = that.U, fm = that.fm, drs = fm.ps.dayRoutes;

      if (e.p) {
        let dr = drs[e.pindex];

        if (e.name == 'spoint' || e.name == 'epoint') {
          // 选择的是站点，但没有出发日期
          if (e.p && e.p.isSta && !dr.goDate) {
            that.$refs[fm.fname].validateField(`dayRoutes.${e.pindex}.goDate`);
            dr[e.name] = null;
            return;
          }

          dr[e.name] = {
            area: e.p.area,
            address: e.p.address,
            name: e.p.name,
            lnglat: e.p.lnglat,
            isSta: e.p.isSta,
            type: e.p.type,
            note: e.p.note
          };

          // 如选择了站点，则打开航班查询弹框
          if (e.p && e.p.isSta) {
            let sp = dr.spoint, ep = dr.epoint;

            // 当前选择的点是开始地点：结束地点不为空，且选择的是站点，则开始地点选择站点后不打开航班/车次查询弹框
            if (e.name == 'spoint' && ep && ep.isSta) {
              return;
            } else if (e.name == 'epoint' && sp && sp.isSta) {
              // 当前选择的点是结束地点：开始地点不为空，且选择的是站点，则结束地点选择站点后不打开航班/车次查询弹框
              return;
            } else {
              that.flightSearchMd({ state: true, name: e.name, pindex: e.pindex });
            }
          }

          // 如果选择的是起点且不是站点，且终点是空，则终点默认为起点
          if (e.name == 'spoint' && !e.p.isSta && dr.epoint && !dr.epoint.lnglat) {
            dr.epoint = U.scopy(dr.spoint);
          }

          // 对应点不为空，则取消验证
          if (dr[e.name].name) U.clearFmVali(that, fm.fname, `dayRoutes.${e.pindex}.${e.name}.name`);
        } else if (e.name == 'amPoints' || e.name == 'pmPoints') {
          dr[e.name] = e.p;
        } else {// 其他点
          dr[e.name] = {
            area: e.p.area,
            address: e.p.address,
            name: e.p.name,
            lnglat: e.p.lnglat,
            isSta: e.p.isSta,
            type: e.p.type,
            note: e.p.note
          };
        }
      }
    },
    /**
     * 删除-多个地点某个地点
     * @param pindex 删除的天行程下标
     * @param cindex 删除的天行程下多个地点的下标
     * @param name 删除的地点数组名称
     */
    delMpsItem(pindex, cindex, name) {
      let that = this, mps = that.fm.ps.dayRoutes[pindex][name];

      if (mps[cindex]) mps.splice(cindex, 1);
    },

    /**********航班查询弹框***********/
    flightSearchMd(e) {
      const that = this, U = that.U, ps = that.fm.ps, dr = ps.dayRoutes[e.pindex];

      if (e.name == 'spoint' || e.name == 'epoint') {
        if (e.state) {// 打开
          if (!dr.goDate) {
            that.$refs[fm.fname].validateField(`dayRoutes.${e.pindex}.goDate`);
          } else if (!(dr.spoint.isSta || dr.epoint.isSta)) {
            // 只要不满足起止地点有一个站点，则提示
            U.qerror('起止地点至少要选择一个站点位置');
          } else if (dr.spoint.isSta && dr.epoint.isSta) {
            U.qerror('起止地点只能存在一个站点');
          } else {
            let type = '', jsType = '', staPoint = null;
            let sp = dr.spoint, ep = dr.epoint;
            if (sp.isSta) {// 开始地点为站点
              type = sp.type;
              jsType = 1;         // 为接
              staPoint = sp;      // 站点为开始地点
            } else if (ep.isSta) {// 结束地点为站点
              type = ep.type;
              jsType = 2;       // 为送
              staPoint = ep;    // 站点为结束地点
            }

            that.md.flightSearch = {
              pindex: e.pindex,
              state: e.state,
              name: e.name,
              date: dr.goDate,
              type: type,
              jsType: jsType,
              staPoint: staPoint
            };
          }
        } else {// 关闭
          console.log('航班查询返回的结果', e);
          if (e.o) {
            let name = e.name;

            if (name == 'spoint' || name == 'epoint') {
              dr.seStaInfo = e.o;

              if (dr.seStaInfo && dr.seStaInfo.jsType == 1) {
                // 飞机增加30分钟，火车增加20分钟
                let addMin = dr.seStaInfo.type == 1 ? 30 : 20;

                // 接-起点为站点，则起点开始时间为降落/进站时间(飞机增加30分钟，火车增加20分钟)
                let dut = U.date2str(new Date(U.str2date(dr.seStaInfo.downUpTime).getTime() + 1000 * 60 * addMin));
                console.log('增加时间后的时间', dut);
                // 日期应该变为航班查询的降落日期
                dr.goDate = dut.split(' ')[0];
                dr.stime = dut.split(' ')[1];
              } else {
                // 送-终点为站点，则起点结束时间为起飞/出站时间
                dr.etime = dr.seStaInfo.downUpTime.split(' ')[1];
              }
            }
          }

          that.md.flightSearch.state = e.state;
        }
      } else {// 查询航班/车次
        that.md.flightSearch = {
          state: e.state,
          name: e.name,
          type: '',
          jsType: '',
        };
      }
    },
    /**
     * 添加-下一天行程
     * @param 当前点击按钮所在index
     */
    addDayRoute(index) {
      let that = this, U = that.U, drs = that.fm.ps.dayRoutes, resList = [];

      let dr = drs[index];
      if (dr) {
        // 遍历当前数组
        drs.forEach((it, i) => {
          if (i < index) {
            resList.push(it);
          } else if (i == index) {
            resList.push(it);

            // 新增一项
            let newDr = U.scopy(dayRoute);
            // 出发日期相对操作行增加一天
            if (it.goDate) newDr.goDate = U.addDayForTime(it.goDate, 1);

            if (it.epoint && it.epoint.lnglat) {
              // 出发地点改为上一天行程的结束地点；
              newDr.spoint = U.scopy(it.epoint);
              // 结束地点改为上一天行程的结束地点；
              newDr.epoint = U.scopy(it.epoint);
            }

            resList.push(newDr);
          } else {
            // 当前操作行之后的数据日期全部+1天
            if (it.goDate) it.goDate = U.addDayForTime(it.goDate, 1);
            resList.push(it);
          }
        });
        that.fm.ps.dayRoutes = resList;
      }
    },
    /**
     * 删除-某一行行程
     * @param 当前点击按钮所在index
     */
    delDayRoute(index) {
      let that = this, U = that.U, drs = that.fm.ps.dayRoutes;

      let dr = drs[index];
      that.U.qconfim(`确定删除【${dr.goDate}】的行程吗？`).then(r => {
        if (r) {
          if (dr) {
            // 遍历当前数组
            drs.forEach((it, i) => {
              if (i > index) {
                // 当前操作行之后的数据日期全部减1天
                if (it.goDate) it.goDate = U.addDayForTime(it.goDate, -1);
              }
            });
            // 删除操作行
            drs.splice(index, 1);
          }
        }
      });
    },
    // 计算订单总价 
    calcOrderTotalPrice() {
      const that = this, FV = that.FV, ps = that.fm.ps;

      // 运价 车辆数不能为空，否则不计算
      if (!ps.transportPrice || !ps.cars || !FV.isNumber(ps.transportPrice) || !FV.isNumber(ps.cars)) {
        ps.orderTotalPrice = 0;
        return;
      } else {
        let totalPrice = parseFloat(ps.transportPrice) * parseInt(ps.cars);

        // 验证并累计其他费用
        if (FV.isNumber(ps.otherFees) && ps.otherFees) {
          totalPrice += parseFloat(ps.otherFees);
        }

        ps.orderTotalPrice = totalPrice;
      }
    },
    /**
     * 提交表单
     */
    onSubmit() {
      const that = this, U = that.U, ps = that.fm.ps;

      that.$refs[that.fm.fname].validate((valid) => {
        if (!valid) {
          return false;
        } else if (ps.dayRoutes.length == 0) {
          U.qerror('至少需添加一天行程');
          return false;
        } else {
          that.fm.sb.load = true;
          let loading = this.U.qloading('提交中，请稍后...');

          /*=======处理参数==========*/
          let p = {};
          // 修改订单的订单编号
          p.orderNum = [ps.orderNum];
          // 下单客户-用户名
          p.companyCusUname = ps.useCarUname;
          // 下单客户操作员-用户名
          p.dutyService = ps.operator;
          // 乘车联系人
          p.routeLink = `${ps.routeLink.name}-${ps.routeLink.phone}`;
          // 下单客户业务员
          p.serviceMan = `${ps.serviceMan.uname}-${ps.serviceMan.name}-${ps.serviceMan.phone}`;
          // 团号
          p.routeName = ps.groupNum;
          // 需求座位数
          p.needSeats = ps.seats;
          // 人数
          p.customers = ps.customers;
          // 需求车辆数
          p.needCars = ps.cars;
          // 需求天数
          p.useCarDays = ps.useCarDays;
          // 单车运价
          p.eachPrice = ps.transportPrice;
          // 运价（此运价是订单总价=运价*车辆数）
          p.price = U.num(ps.transportPrice * ps.cars);
          // 其他费用
          p.otherPrice = ps.otherFees;
          // 提醒师傅现收
          p.remDriverCharge = ps.remindRouteCash;
          // 定金
          p.handSelPrice = ps.deposit;
          // 行程简称
          p.routeSimpleName = ps.routeShort == '包车' ? that.routeShort_value + ps.routeShort : ps.routeShort;
          // 行程详情
          p.routeDetail = ps.routeDetail;
          // 客户备注
          p.cusNote = ps.cusNote;
          // 驾驶员备注
          p.driverNote = ps.driverNote;
          // 业务员备注
          p.serviceNote = ps.salesmanNote;
          // 是否通知驾驶员
          p.isNotice = ps.isNotice;
          console.log('交通车提交参数', p);



          // 每日行程信息
          let dayRoutes = [];
          ps.dayRoutes.forEach((it, i) => {
            let amPoints = []; // 上午行程
            if (it.amPoints) {
              it.amPoints.forEach(amit => {
                amPoints.push(`${amit.area.split('-')[1]} ${amit.name}=${amit.lnglat}=${amit.area}=${amit.isSta ? 1 : 0}`);
              });
            }

            let pmPoints = []; // 下午行程
            if (it.pmPoints) {
              it.pmPoints.forEach(pmit => {
                pmPoints.push(`${pmit.area.split('-')[1]} ${pmit.name}=${pmit.lnglat}=${pmit.area}=${pmit.isSta ? 1 : 0}`);
              });
            }

            let staInfos = []; // 站点航班/车次查询信息数组
            if (it.seStaInfo) staInfos.push(`${it.seStaInfo.flightTrainNo}=${it.seStaInfo.downUpTime}=${it.seStaInfo.type}=${it.seStaInfo.jsType}=${it.seStaInfo.selStaName}`);

            // 结束日期（如果开始时间大于结束时间，则说明跨天，则结束日期需要+1天）
            let edate = it.goDate;
            if (U.str2date(`${it.goDate} ${it.stime}`).getTime() > U.str2date(`${it.goDate} ${it.etime}`).getTime()) {
              edate = U.addDayForTime(edate, 1);
            }

            dayRoutes.push({
              // 开始时间
              stime: `${it.goDate} ${it.stime}`,
              // 结束时间
              etime: `${edate} ${it.etime}`,
              // 途径高速
              highSpeed: it.wayHighSpeed,
              // 出发地点
              spoint: `${it.spoint.area.split('-')[1]} ${it.spoint.name}=${it.spoint.lnglat}=${it.spoint.area}=${it.spoint.isSta ? 1 : 0}`,
              // 上午行程
              morningPoint: amPoints.join('/@'),
              // 午餐地点
              lunchPoint: (it.lunchPoint && it.lunchPoint.lnglat) ? `${it.lunchPoint.area.split('-')[1]} ${it.lunchPoint.name}=${it.lunchPoint.lnglat}=${it.lunchPoint.area}=${it.lunchPoint.isSta ? 1 : 0}` : null,
              // 下午行程
              afternoonPoint: pmPoints.join('/@'),
              // 晚餐地点
              dinnerPoint: (it.dinnerPoint && it.dinnerPoint.lnglat) ? `${it.dinnerPoint.area.split('-')[1]} ${it.dinnerPoint.name}=${it.dinnerPoint.lnglat}=${it.dinnerPoint.area}=${it.dinnerPoint.isSta ? 1 : 0}` : null,
              // 到达地点
              epoint: `${it.epoint.area.split('-')[1]} ${it.epoint.name}=${it.epoint.lnglat}=${it.epoint.area}=${it.epoint.isSta ? 1 : 0}`,
              // 站点信息
              stationInfo: staInfos.join('/@'),

              /*******已取消的参数***********/
              // 可换车（取消）
              dayChangeCar: 0,
              // 临空时间（移至派车操作列表）
              freeInfo: [],

            });
          });
          p.dayRouteInfo = dayRoutes;

          /**********已取消的参数****************/
          // 订单业务类型（后台自动计算）
          p.serviceType = '';
          // 是否自己用车（已取消）
          p.useSelf = 0;


          // 所同步修改的子订单编号数组字符串
          that.dg.selRows.forEach(onit => { p.orderNum.push(onit.orderNum); });
          console.log('提交参数对象', p);

          if (ps.isCopy) {// 复制子订单（在所属主订单下新增子订单）
            // 新增主订单编号
            p.mainOrderNum = ps.mainOrderNum;

            orderService.copyChildOrder(p).then(res => {
              that.fm.sb.load = false;
              U.qclose(loading);

              if (!res || res.code != 1) {
                U.qerror(res.msg);
              } else {
                U.qsuccess(res.msg);

                // 关闭弹框
                that.closeMd();

                // 调用父组件方法-重新加载数据
                that.$emit('reloadDg');
              }
            });
          } else {// 修改主订单
            orderService.updChildOrder(p).then(res => {
              that.fm.sb.load = false;
              U.qclose(loading);

              if (!res || res.code != 1) {
                U.qerror(res.msg);
              } else {
                U.qsuccess(res.msg);

                // 关闭弹框
                that.closeMd();

                // 调用父组件方法-重新加载数据
                that.$emit('reloadDg');
              }
            });
          }
        }
      });
    },
    // 刷新订单列表
    getDgList() {
      // 调用父组件方法-重新加载数据
      this.$emit('reloadDg');
    },

  }
}
</script>
<style lang="less" scoped>
.upd-order ::v-deep {

  .upd-order-md {
    .el-dialog__body {
      padding-top: 0px !important;

      .el-tab-pane {
        overflow-y: auto;
      }
    }
  }

  .upd-order-fm {
    // 使用弹框的底部滚动条，表单的滚动条隐藏
    min-width: 1360px;
    overflow-x: hidden;
    padding-right: 10px;
  }

  .el-textarea textarea {
    height: 150px !important;
  }

  // 添加用车客户
  .add-btn {
    position: absolute;
    right: -20px;
    bottom: 6px;
    cursor: pointer;
  }

  .add-route-line {
    padding: 5px;
    // margin-bottom: 10px;
    // border: 1px solid #E6A23C;
    border-radius: 5px;
    max-height: calc(100vh - 595px);
    overflow-y: auto;

    &>div>div {
      margin-left: 0px !important;
    }

    .flight-num-info {
      margin-top: 5px;
      padding: 5px;
      border-top: 1px solid #efefef;
      color: #ff6300;

      span,
      label {
        padding: 0 5px;
        border: 1px solid #ff6300;
        border-radius: 5px;
        margin-right: 10px;
        font-weight: normal;

        i {
          cursor: pointer;
        }
      }

      label:hover {
        opacity: 0.8;
      }
    }
  }

  // 上午/下午行程-多个地点
  .am-points,
  .pm-points {
    .el-input__inner {
      cursor: pointer;
    }

    .el-input-group__append {
      padding: 0 5px;
    }
  }

  .text-note .el-form-item .el-form-item__label {
    line-height: 18px;
  }

  .page-explain {
    border-top: 1px solid #efefef;
    margin-top: 10px;
    padding: 10px 0;
  }

}
</style>
